home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93b.txt
/
000085_icon-group-sender _Fri May 14 09:46:40 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1993-06-16
|
1KB
Received: by cheltenham.cs.arizona.edu; Fri, 14 May 1993 08:58:37 MST
Date: Fri, 14 May 93 09:46:40 -0400
Message-Id: <9305141346.AA10725@sanborn.bbn.com>
To: icon-group@cs.arizona.edu
Subject: string stripping
From: Sean Boisen <sboisen@BBN.COM>
Sender: sboisen@bbn.com
Reply-To: sboisen@bbn.com
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
This is so basic it's probably covered in the second week of Icon 101,
but since i never took the class ...
If i have a string and i want to strip out certain characters
(internal ones, so trim won't do it), i can do it like this
# assume you want to remove hyphens and periods
full := "abc-def.ghi"
bare := ""
badchars := '-.'
every c := !full do
# test whether the intersection of c and badchars is empty
if *(c ** badchars) = 0 then bare ||:= c
But this seems awfully clunky, and i was disappointed that i couldn't
come up with a tighter way to do it: am i missing some more idiomatic
way to express this? Note there's two parts that i perceive as clunky:
the testing of whether c is in badchars (i suppose you could make
badchars a string and use find instead), and the control structure
with explicit generation and assignment to a new string.
Any Icon stylists want to offer some pointers on improvements?
Sean